CC		=	gcc
CXX		=	g++
ASM		=	nasm
ALINK	=	alink
DEPS	=	main.c
OBJ		=	main.o
CFLAGS	=	-g
LFLAGS	= 	-L. -lmatrix
INCLUDES=	-I.

all: matrix main

main: main.o
	$(CC) -g -o main.exe main.o $(LFLAGS)

main.o: main.c
	$(CC) $(CFLAGS) $(INCLUDES) -g -c -o main.o main.c

main1: main1.o
	$(CC) -o main.exe main1.o $(LFLAGS)

main1.o: main.asm
	$(ASM) -f win32 -o main1.o -l main1.lst main.asm
	
matrix: matrix.obj
	$(ALINK) -subsys console matrix.obj -oPE -dll -o matrix.dll
	pexports matrix.dll > matrix.def
	dlltool -D matrix.dll -d matrix.def -l libmatrix.a
	
matrix.obj: matrix.asm
	$(ASM) -g -f obj -l matrix.lst -o matrix.obj matrix.asm
	
clean:
	del *.o main.exe main.s *.a *.obj *.dll *.def *.lst

asm:
	$(CC) $(INCLUDES) -S -masm=intel -m32 -fno-asynchronous-unwind-tables -o main.s main.c
	$(CC) $(INCLUDES) -S -masm=intel -m32 -fno-asynchronous-unwind-tables -o mx_funcs.s mx_funcs.c
	
mx_funcs: mx_funcs.o
	gcc -Wl,-s -shared -mthreads -Wl,--out-implib,libmx_funcs.a -o mx_funcs.dll mx_funcs.o  
	
mx_funcs.o: mx_funcs.c
	gcc -c -O2 -Wall -I. -o mx_funcs.o mx_funcs.c

